package com.swn.common.util;

import java.util.Iterator;
import java.util.UUID;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 * UUID生成器
 * 
 */
public class UUIDUtil {
	public static String getUUID() {
		return UUID.randomUUID().toString().replace("-", "");
	}

	public static void main(String[] args) throws ScriptException {
		System.out.println(UUIDUtil.getUUID());
		ScriptEngineManager manager = new ScriptEngineManager();
		ScriptEngine script = manager.getEngineByName("JavaScript");
		Object o = script.eval("1>=1&&2<1");
		System.out.println(o);
	}
	
	 /* public static JSONObject transObject(JSONObject o1){
	        JSONObject o2=new JSONObject();
	         Iterator it = o1.keys();
	            while (it.hasNext()) {
	                String key = (String) it.next();
	                Object object = o1.get(key);
	                if(object.getClass().toString().endsWith("String")){
	                    o2.accumulate(key.toLowerCase(), object);
	                }else if(object.getClass().toString().endsWith("JSONObject")){
	                    o2.accumulate(key.toLowerCase(), transObject((JSONObject)object));
	                }else if(object.getClass().toString().endsWith("JSONArray")){
	                    o2.accumulate(key.toLowerCase(), transArray(o1.getJSONArray(key)));
	                }
	            }
	            return o2;
	    }
	    public static JSONArray transArray(JSONArray o1){
	        JSONArray o2 = new JSONArray();
	        for (int i = 0; i < o1.size(); i++) {
	            Object jArray=o1.getJSONObject(i);
	            if(jArray.getClass().toString().endsWith("JSONObject")){
	                o2.add(transObject((JSONObject)jArray));
	            }else if(jArray.getClass().toString().endsWith("JSONArray")){
	                o2.add(transArray((JSONArray)jArray));
	            }
	        }
	        return o2;
	    }*/
}